package com.yanqu.road.server.manger.cricket.skillhandler.startround.handler;

import com.yanqu.road.entity.cricket.helper.AddHpResult;
import com.yanqu.road.pb.cricket.CricketProto;
import com.yanqu.road.server.gameplayer.module.cricket.battle.CricketGame;
import com.yanqu.road.server.gameplayer.module.cricket.model.BattleData;
import com.yanqu.road.server.gameplayer.module.cricket.model.SkillData;
import com.yanqu.road.server.manger.cricket.skillhandler.startround.CricketSkillStartRoundStrategy;
import com.yanqu.road.utils.RandomHelper;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class CricketSkill150Strategy implements CricketSkillStartRoundStrategy {

    /**
     * 技能处理-轰天雷-攻击前{0}概率出发雷击造成对方本回合无法攻击的麻痹效果。
     * @param cricketGame 本局对局对象
     * @param skillData 技能数据
     * @param action 我方
     * @param target 对方
     * @param roundId 第几回合
     * @param attackRoundBuilder 返回PB结构体
     * @return
     */
    @Override
    public boolean skillHandle(CricketGame cricketGame, SkillData skillData, BattleData action, BattleData target, int roundId, CricketProto.CricketAttackRound.Builder attackRoundBuilder) {
        int i = RandomHelper.rand1000();;
        if (i < skillData.getSkillEffect().getP1()) {
            skillData.effectAmountInc();
            target.setFreeze(target.getFreeze() + 1);
            target.setFreezeSkillId(skillData.getSkillId());
            CricketProto.CricketBattleFrame.Builder newBattleFrameBuilder = cricketGame.newBattleFrameBuilder();
            newBattleFrameBuilder.setActionUserId(action.getUserId());
            newBattleFrameBuilder.setTargetUserId(target.getUserId());
            newBattleFrameBuilder.setSkillId(skillData.getSkillId());
            cricketGame.fillRemainHp(newBattleFrameBuilder);
            attackRoundBuilder.addStartRound(newBattleFrameBuilder);
        }
        return false;
    }
}
